#ifndef GAMEBOARD_H
#define GAMEBOARD_H

#include <QWidget>
#include <QGridLayout>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QPushButton>
#include <QKeyEvent>
#include <QMessageBox>
#include "GameController.h"

class GameBoard : public QWidget
{
    Q_OBJECT

public:
    explicit GameBoard(QWidget *parent = nullptr);
    ~GameBoard();

protected:
    void keyPressEvent(QKeyEvent *event) override;

private slots:
    void updateBoard();
    void showGameOver();
    void restartGame();
    void updateScore(int score);
    void updateTileLabel(QLabel *label, int value);

private:
    void setupUI();
    void setupGameGrid();
    QLabel* createTileLabel(int value);
    QString getTileColor(int value);
    QString getTileTextColor(int value);

    GameController *gameController;
    QGridLayout *gridLayout;
    QLabel *scoreLabel;
    QLabel *bestScoreLabel;
    QPushButton *restartButton;
    QVector<QVector<QLabel*>> tileLabels;
};

#endif // GAMEBOARD_H
